<?php
#GetArchivePosition
#$GetPosition = $GLOBALS['MYT']->db_array("SELECT * FROM WHERE  = ");
$ArchivePosition = 100000;
if($_GET['RSID']<=$ArchivePosition){$SelectedDB = $__DBS;}else{$SelectedDB = $__DBT;}

require_once($GLOBALS['BIB'] . "Pr_db/pr_operative.mex");
MYTCONN();
$FlgMotive = '';
$EnableActions = 'block';
$wintitle = '';

$form_fix = '" disabled readonly="';

$GET = $GLOBALS['MYT']->db_array($Pr_GetInvoiceExtent . "FraID = {$_GET['RSID']}");

$GETSYSSETTINGS = $GLOBALS['MYT']->db_array("SELECT ast_Value
	FROM systemoffice.administration_settings
	INNER JOIN bonus_productstocks ON bss_Product = ast_Value AND bss_Office = {$GET[1]['FraOrigen0']}
	WHERE ast_ID = 2 AND bss_Time < '{$GET[1]['FraFechaIngreso']}'");

if ($GET[1]['FraCambio'] > 0) {
    $GET[1]['FraTasa'] = $GET[1]['FraTasaAgn'] / $GET[1]['FraCambio'];
}

if ($GET[1]['FraStatus'] == 2 && $GET[1]['FraAlbaran'] == 0 && ($_SESSION[$SESSGR] == 2 || $_SESSION[$SESSGR] == 0)) {
    $ActivStat = 'IN (1,2)';
    $StMode = '';
    $wintitle = 'Anular Remessa';
} elseif ($GET[1]['FraStatus'] == 18) {
    $ActivStat = 'IN (18)';
    $StMode = '';
    $wintitle = 'Pedir Cancelamento';
    $EnableActions = 'none';
} elseif ($GET[1]['FraStatus'] == 16) {
    $ActivStat = 'IN (16,11,18)';
    $StMode = '';
    $wintitle = 'Pagar Remessa';
    $EnableActions = 'none';
} elseif (in_array($GET[1]['FraStatus'], array(1, 9, 21))) {
    $ActivStat = '= ' . $GET[1]['FraStatus'];
    $StMode = ' readonly="" disabled ';
    $GetHistory = $GLOBALS['MYT']->db_array("SELECT * FROM hd_historiagiros WHERE edg_Operacion = {$GET[1]['FraID']}");
    if (isset($GetHistory[1])) {
        $FlgMotive = 'Motivo: ' . $GetHistory[1]['edg_Motivo'];
    }
} else {
    $ActivStat = '= ' . $GET[1]['FraStatus'];
    $StMode = ' readonly="" disabled ';
}
form_pr('pp_frm', '', '', 'post');?>
<div id="Inv_ActionButtons" style="display:<?php echo $EnableActions; ?>">
    <?php
if (isset($GETSYSSETTINGS[1]['ast_Value']) && $GET[1]['FraModo'] == 1) {
	mn_field('hidden', 'ED', 'bns_time', $GET[1]['FraFechaIngreso'], '', '', '', '');
	mn_field('hidden', 'ED', 'OBJCTCL', $GET[1]['CliNumero'], '', '', '', '');

	mn_field('button', 'ED', 'Bns_Delivery', 'Entregar Brinde', '', '', '', '" style="position:absolute;top:5px;left:450px" onclick="
		docuemnt.pp_frm.action=\'Modules/MF93FL27/remkdestben.php\';
		subform(\'pp_frm\',\'bns_delivery\');');
}

mn_field('button', 'ED', 'Save', 'Imprimir', '', '', '', '" style="position:absolute;top:5px;left:600px" onclick="
			newprint(\'Aplications/Export_Print.mex?MOD=XFK0WK2A&OB=' . $GET[1]['FraID'] . '&ID=V1\',\'Printer\');');
?></div>
<div id="Inv_Action"></div>
<div id="bns_delivery"></div>
<?php include 'frm_transfermodel.php'; ?>
</form>
